Visualization
Model Comparison
# Importing the library 'haven' and using it's built-in read_sas function to save the data to a dataframe. library(haven) library(dplyr)
## ## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats': ## ## filter, lag
## The following objects are masked from 'package:base': ## ## intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ── ## ✔ forcats 1.0.0 ✔ readr 2.1.4 ## ✔ ggplot2 3.4.3 ✔ stringr 1.5.0 ## ✔ lubridate 1.9.2 ✔ tibble 3.2.1 ## ✔ purrr 1.0.2 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ── ## ✖ dplyr::filter() masks stats::filter() ## ✖ dplyr::lag() masks stats::lag() ## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
df <- read.csv('midterm.csv')
head(df)
## yod payfix pay_ub92 age sex raceethn provider moa yoa mod admtype asource ## 1 18 NA 9 0 1 1 7214 1 18 1 4 S ## 2 18 NA 2 76 2 1 7214 1 18 1 3 1 ## 3 18 NA 6 50 2 1 7214 12 17 1 2 1 ## 4 18 NA 4 0 1 7 7214 1 18 1 4 S ## 5 18 NA 13 0 1 1 7214 12 17 1 4 S ## 6 18 NA 4 0 2 9 7214 12 17 1 4 T ## preopday los service icu ccu dispub92 payer drg trandb randbg randbs orr ## 1 2 2 0 0 0 1 6 795 2400 2400 0 615 ## 2 0 1 0 0 0 1 0 740 3500 3500 0 29415 ## 3 -1 3 0 0 0 6 5 330 10500 10500 0 59550 ## 4 NA 4 0 0 0 1 G 795 4800 4800 0 0 ## 5 2 35 0 0 0 1 7 793 76400 37200 39200 615 ## 6 0 17 0 0 0 20 G 789 166600 0 166600 0 ## anes seq lab dtest ther blood phar other patcon bwght total tot ## 1 0 0 286 285 0 0 67 0 0 NA 3653 3653 ## 2 570 2141 3821 202 0 0 1062 3364 0 NA 44075 44075 ## 3 570 8796 8094 534 126 1278 4136 5651 0 NA 99235 99235 ## 4 0 0 260 285 0 0 67 0 0 NA 5412 5412 ## 5 0 84 4697 3542 2156 0 6053 0 0 NA 93547 93547 ## 6 0 373 5757 2120 19300 1483 11733 0 0 NA 207366 207366 ## ecodub92 b_wt pt_state diag_adm ancilar campus er_fee er_chrg er_mode ## 1 389 RI Z3800 1253 0 0 0 9 ## 2 0 RI C541 40575 0 0 0 9 ## 3 0 RI C569 88735 0 0 0 9 ## 4 397 RI Z3801 612 0 0 0 9 ## 5 281 MA Z3801 17147 0 0 0 9 ## 6 84 MA P0725 40766 0 0 0 9 ## obs_chrg obs_hour psycchrg nicu_day ## 1 00000000 0 0 NA ## 2 00000000 0 0 NA ## 3 00000000 0 0 NA ## 4 00000000 0 0 NA ## 5 00000000 0 0 400 ## 6 00000000 0 0 1700